Skip to content

feat(sr): add hybrid Session Replay support on Android - #1129

Draft
JuanNaranjoDD wants to merge 7 commits into
developfrom
juan.naranjo/hybrid-session-replay-android
Draft

feat(sr): add hybrid Session Replay support on Android#1129
JuanNaranjoDD wants to merge 7 commits into
developfrom
juan.naranjo/hybrid-session-replay-android

Conversation

@JuanNaranjoDD

Copy link
Copy Markdown
Contributor

What and why?

Adds hybrid (add-to-app) Session Replay support on Android, mirroring the iOS support added in #1100.

When a Flutter module runs inside a native Android host, Session Replay currently records it as its own standalone session, disconnected from the host's replay. This change lets the Flutter view be recorded into the host application's replay instead, so a single session shows the native and Flutter UI composited together.

How?

Process-wide ownership. FlutterSessionReplayManager.shared owns the single feature, core, engine registry, and slot registry. FlutterSessionReplayBridge becomes a per-engine class (keyed by an engine token) rather than an object, so
multiple Flutter engines in one process share one feature and one context broadcast instead of fighting over it.

Ordering invariant. The player can only composite a Flutter record into a placeholder wireframe that already exists in the same segment. Slot IDs are therefore minted only in registerSlot and never on read, and segments buffer in pendingSegments (capped) while the embedding state is still UNKNOWN, so nothing is emitted before its placeholder can exist. The native side holds records until the placeholder is written.

Host API. enableSessionReplay() is exposed on FlutterFragment, FlutterActivity, and FlutterView, re-registering the slot on ON_START.

Feature names. The Flutter features are renamed to flutter-session-replay and flutter-session-replay-resources, matching iOS, so registering them no longer evicts the native Session Replay module from the core.

Review checklist

  • This pull request has appropriate unit and / or integration tests
  • This pull request references a Github or JIRA issue

Record a Flutter view embedded in a native Android host into the host's replay instead of a standalone session, mirroring the iOS support.

Add FlutterSessionReplayManager, a process-wide singleton owning the feature, core and engine registry, and make FlutterSessionReplayBridge per-engine so multiple engines share one feature. Route embedded segments and resources through _SessionReplayInternalProxy, reached via compileOnly and a guarded Class.forName check so pure-Flutter apps degrade instead of crashing. Expose enableSessionReplay() on FlutterFragment/FlutterActivity/FlutterView.
@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Aug 24, 2026

Copy link
Copy Markdown

Pipelines

Unblock PR with BitsAI

⚠️ Warnings

Your PR has failed checks. Please review the issues below and take necessary action before merging.

🚦 1 Pipeline job failed

DataDog/dd-sdk-flutter | build-android — 🔧 Needs a code fix, caused by this PR

View more details · View in GitLab

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 1ee7852 | Docs | View more details | Give us feedback!

@fuzzybinary

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7bcd24ac2a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@fuzzybinary fuzzybinary left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Codex's comments might be worth addressing. Also, once it's ready I'd like @jonathanmos to take a look - specifically at the need for the extra GSON work. I'd love to avoid that if possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants